#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include "BinaryTree.h"
using namespace std;

void insert(int data, BinaryTree* node)
{
	while ( node )
	{
		if ( data == node->data )
			return;
		else if ( data < node->data )
			node = node->left;
		else if ( data > node->data )
			node = node->right;
	}
	node = new BinaryTree();
	node->data = data;
	node->left = node->right = NULL;
}

BinaryTree* search(int data, BinaryTree* node)
{
	while ( node )
	{
		if ( data == node->data )
			return node;
		else if ( data < node->data )
			node = node->left;
		else if ( data > node->data )
			node = node->right;
	}
	return NULL;
}

void destroyTree(BinaryTree*& node)
{
	if ( node == NULL )
		return;
	destroyTree(node->left);
	destroyTree(node->right);
	delete node;
	node = NULL;
}